#include <type_traits>
#include <iostream>

// 定义用于判断强枚举的模板函数
template<typename T>
constexpr bool is_scoped_enum() {
    return std::is_enum_v<T> && !std::is_convertible_v<T, std::underlying_type_t<T>>;
}

// 枚举类型定义
enum class AccessLevel : int { None, Read, Write, Admin };
enum NormalEnum { Low, Medium, High };

// 模板函数，根据枚举类型执行操作
template<typename Enum>
void checkAndPerformAction(Enum level) {
    if constexpr (is_scoped_enum<Enum>()) {
        std::cout << "Scoped enum detected. Performing type-safe comparison." << std::endl;
        // 执行基于枚举的安全操作
        if (level == AccessLevel::Admin) {
            std::cout << "Admin access granted." << std::endl;
        }
    } else {
        std::cout << "Normal enum detected. Performing general comparison." << std::endl;
        // 执行普通枚举操作，可能需要类型转换
        if (static_cast<int>(level) == static_cast<int>(High)) {
            std::cout << "High access granted." << std::endl;
        }
    }
}

int main() {
    AccessLevel adminLevel = AccessLevel::Admin;
    NormalEnum userLevel = High;

    // 测试强枚举
    checkAndPerformAction(adminLevel);
    // 测试普通枚举
    checkAndPerformAction(userLevel);

}